using DevFramework.Entities.Concrete;
using FluentNHibernate.Mapping;

namespace DevFramework.DataLayer.Concrete.NHibernate.Mapping
{
    public partial class OrderDetailMap : ClassMap<OrderDetail>
    {
        public OrderDetailMap()
        {
            Table(@"OrderDetails");

            LazyLoad();

            CompositeId()
                .KeyProperty(x => x.OrderId, set =>
                {
                    set.Type("Int32");
                    set.ColumnName("OrderID");
                    set.Access.Property();
                })
                .KeyProperty(x => x.ProductId, set =>
                {
                    set.Type("Int32");
                    set.ColumnName("ProductID");
                    set.Access.Property();
                });

            Map(x => x.UnitPrice)
              .Column("UnitPrice")
              .CustomType("Decimal")
              .Access.Property()
              .Generated.Never()
              .Default(@"0")
              .CustomSqlType("money")
              .Not.Nullable()
              .Precision(19)
              .Scale(4);

            Map(x => x.Quantity)
              .Column("Quantity")
              .CustomType("Int16")
              .Access.Property()
              .Generated.Never()
              .Default(@"1")
              .CustomSqlType("smallint")
              .Not.Nullable()
              .Precision(5);

            //References(x => x.Order)
            //  .Class<Order>()
            //  .Access.Property()
            //  .Cascade.None()
            //  .LazyLoad()
            //  .Columns("OrderID");

            //References(x => x.Product)
            //  .Class<Product>()
            //  .Access.Property()
            //  .Cascade.None()
            //  .LazyLoad()
            //  .Columns("ProductID");
        }
    }
}
